package servlets;

import dao.CommentEntityFacadeLocal;
import dao.ContentEntityFacadeLocal;
import dao.RateEntityFacadeLocal;
import dao.UserEntityFacadeLocal;
import entities.UserEntity;
import java.io.IOException;
import java.util.Properties;
import javax.ejb.EJB;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import utils.Menu;
import utils.MenuItem;

/**
 * 
 * @author andrei costache
 *
 */
public class UserViewController extends UserController {

        @EJB public RateEntityFacadeLocal rateDAO;
        @EJB public CommentEntityFacadeLocal commentDAO;
        @EJB public ContentEntityFacadeLocal contentDAO;

        
	@Override
	public void doRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

            super.doRequest(request, response);
            RequestDispatcher view = null;

            request.setAttribute("messages", msg);

            //request.setAttribute("mymsg",new String("test"));
            HttpSession session = request.getSession();
            UserEntity user = (UserEntity)session.getAttribute("user");

            request.setAttribute("ratedContents",rateDAO.findFullContentsByUid(user.getUid()));

            request.setAttribute("commentedContents",commentDAO.findCommentedContentByUid(user.getUid()));

            view = request.getRequestDispatcher("/jsp/UserViewProfile.jsp");
            view.forward(request, response);
           
        }
}
